package kr.saeildamil.androidstudty.ch17;

import java.io.File;

import kr.saeildamil.androidstudty.R;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.widget.Toast;

public class CallOther extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch17_callother);
	}
	public void mOnClick(View v){
		Intent intent;
		switch (v.getId()) {
		case R.id.ch17_callother_web:
			intent=new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.naver.com"));
			startActivity(intent);
			break;
		case R.id.ch17_callother_dial:
			intent=new Intent(Intent.ACTION_CALL,Uri.parse("tel:010-4031-7994"));
			startActivity(intent);
			break;
		case R.id.ch17_callother_picture:
			String sdPath=Environment.getExternalStorageDirectory().getAbsolutePath();
			File file=new File(sdPath+"/childs.png");
			Uri uri=Uri.fromFile(file);
			
			intent=new Intent(Intent.ACTION_VIEW,uri);
			intent.setDataAndType(uri, "image/png");
			Toast.makeText(this, sdPath, Toast.LENGTH_SHORT).show();
			startActivity(intent);
			break;
		case R.id.ch17_callother_other:
			intent=new Intent(Intent.ACTION_MAIN);
			//intent.setClassName("com.example.otherapp", "com.example.otherapp.MainActivity");
			ComponentName componentName=new ComponentName("com.example.otherapp", "com.example.otherapp.MainActivity");
			intent.setComponent(componentName);
			startActivity(intent);
			break;
		case R.id.ch17_callother_calladd:
			intent=new Intent(Intent.ACTION_MAIN);
			intent.setClassName("kr.co.saeildamil.add", "kr.co.saeildamil.add.Add");
			intent.putExtra("left", 3);
			intent.putExtra("right", 4);
			startActivity(intent);
			break;
		}
	}
}
